package org.zfes.snowier.cloud.zbss.cms.router.service.content;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.content.dto.CmsContentViewDto;
import org.zfes.snowier.cloud.zbss.cms.content.model.CmsContent;
import org.zfes.snowier.cloud.zbss.cms.content.service.ICmsContentService;
@Controller("org.zfes.snowier.cloud.zbss.cms.router.service.content.CmsContentController") 
@RequestMapping("/cms/service/content/cmsContent")
public class CmsContentController extends BaseController {

	
	@Autowired
	private ICmsContentService cmsContentService;
	
	@RequiresPermissions(value="cmsContent:loadCmsContentDataSet",desc="内容列表")
    @RequestMapping(value="/loadCmsContentDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsContentDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsContentService.loadCmsContentDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }

	@RequiresPermissions(value="cmsContent:loadCmsContent",desc="内容加载")
    @RequestMapping(value="/loadCmsContent", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsContent(Long id){
		Optional<CmsContent> ops = cmsContentService.loadCmsContentById(id);
		return ajaxQuery("cmsContent",ops);
    }
	@RequiresPermissions(value="cmsContent:loadCmsContentViewDtoByTagId",desc="某个标签id加载内容")
    @RequestMapping(value="/loadCmsContentViewDtoByTagId", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsContentViewDtoByTagId(Long tagId){
		Map<List<CmsContentViewDto>,Integer> map= cmsContentService.loadCmsContentViewDtoByTagId(tagId);
		return ajaxQuery("map",map);
    }
}